<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="s"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>

<!DOCTYPE html>
<html lang="en">
<head>
<title><s:message code="app.title" /></title>
<%@ include file="Include.jsp"%>
<script type="text/javascript">
$(document).ready(function() {
	$("#branchname").focus();
	
	$('#cancelBranch').click(function(){
		$('#cancelForm').attr('action','EditCompany');
		$('#cancelForm #companyId').val($('#branchForm #companyId').val());
		$('#cancelForm').attr('method','get');
		$('#cancelForm').submit();
	});
	
});

function addBranchDetail(){
	$('#branchForm').attr('action','AddBranch');
	$('#branchForm').attr('method','post');
	$('#branchForm').submit();
};
	
</script>
</head>
<body>
	<div class="container">
		<%@ include file="Menu.jsp"%>
		<h2><s:message code="branchForm.addheader" /></h2>
		<hr>
		<form id="cancelForm">		
			<input type="hidden" name="companyId" id="companyId"> 	
		</form>
		<form:form class="form-horizontal" method="post" name="branchForm" id="branchForm" commandName="BranchForm"
	           modelAttribute="branchForm" >
			
			<table class="table table-bordered">
			<tr>
				<th width="15%"><form:label path="branchname"><s:message code="branchForm.branchname" />
				<font color="red">*</font>
				</form:label></th>
				<td width="*">
				<form:hidden path="branchid" cssClass="input-medium" id="branchid" />
				<form:hidden path="companyId" id="companyId" value="${companyId}"/>
				<form:input path="branchname" cssClass="input-medium" id="branchname" maxlength="40" size="40" tabindex="1" />
				<form:errors cssClass="text-error" path="branchname" />
				</td>
				<th width="15%"><form:label path="branchcode"><s:message code="branchForm.branchcode" />
				<font color="red">*</font>
				</form:label></th>
				<td width="*">
					<form:input path="branchcode" maxlength="20" id="branchcode" cssClass="input-xlarge" />
					<form:errors cssClass="text-error" path="branchcode" />
				</td>
				
			</tr>
			<tr>
				<th width="15%"><form:label path="address"><s:message code="branchForm.address" />
				<font color="red">*</font>
				</form:label></th>
				<td width="*">
					<form:textarea path="address" rows="4" id="address" cssClass="input-xlarge"/>
					<form:errors cssClass="text-error" path="address" />
				</td>
				 
				<th width="15%"><form:label path="cityId"><s:message code="branchForm.city" />
				<font color="red">*</font>
				</form:label></th>
				<td width="*">
					<form:select path="cityId" cssClass="input-medium" id="cityId" >
						<form:option value="">--SELECT-</form:option>
						<form:options items="${cityList}" itemLabel="cityname" itemValue="cityid"/>
					</form:select>
					<form:errors cssClass="text-error" path="cityId" />
				</td>
			</tr>
			<tr>
				<th><form:label path="ctcperson"><s:message code="branchForm.ctcperson" />
				<font color="red">*</font>
				</form:label></th>
				<td><form:input path="ctcperson" cssClass="input-xlarge" id="ctcperson" maxlength="20" />
					<form:errors cssClass="text-error" path="ctcperson" />
				</td>
				
				<th><form:label path="email"><s:message code="branchForm.email" />
				<font color="red">*</font>
				</form:label></th>
				<td><form:input path="email" cssClass="input-xlarge" id="email" maxlength="20" />
					<form:errors cssClass="text-error" path="email" />
				</td>
				
			</tr>
			<tr>
				<th><form:label path="cellno"><s:message code="branchForm.cellno" /></form:label></th>
				<td><form:input path="cellno" cssClass="input-medium" id="cellno" maxlength="10" size="10" />
					<form:errors cssClass="text-error" path="cellno" />
				</td>
				
				<th><form:label path="website"><s:message code="branchForm.website" /></form:label></th>
				<td><form:input path="website" cssClass="input-xlarge" id="website" maxlength="20" />
					<form:errors cssClass="text-error" path="website" />
				</td>
			</tr>
			<tr>
				<th><form:label path="comments"><s:message code="branchForm.comments" /></form:label></th>
				<td colspan="3">
					<form:textarea path="comments" rows="4" id="comments" cssClass="input-xlarge"/>
					<form:errors cssClass="text-error" path="comments" />
				</td>
				
			</tr>
		</table>
			<button class="btn btn-primary" type="submit" id="addBranch"  formaction="AddBranch" formmethod="post"><s:message code="app.add" /></button>
			<button class="btn btn-primary" type="button" id="cancelBranch" >
			<s:message code="app.cancel" /></button>
			
		</form:form>	
		
		 <%@ include file="Footer.jsp"%>
	</div>
</body>
</html>